package com.taorenqi.business.adapter;

import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.taorenqi.business.R;
import com.taorenqi.business.app.MyApp;
import com.taorenqi.business.helper.RecyclerViewHolder;
import com.taorenqi.business.widget.labelview.LabelLinearLayoutView;
import com.taorenqi.data.entity.mine.GiftEntity;

import java.util.List;

/**
 * Created by eric on 2017/9/26.
 */

public class GiftAdapter extends BaseQuickAdapter<GiftEntity,RecyclerViewHolder> {



    public GiftAdapter(List<GiftEntity> commonEntityList) {
        super(R.layout.item_recyclerview_gift,commonEntityList);

    }
    @Override
    protected void convert(final RecyclerViewHolder helper, GiftEntity item) {
        if (item != null){

            helper
                    .setText(R.id.item_gift_money,item.getTask_coupon_money() + "")
                    .setText(R.id.item_gift_name,item.getTask_coupon_name())
                    .setText(R.id.item_gift_condition,"使用条件："+ item.getTask_coupon_condition())
                    .setText(R.id.item_gift_time, "有效期至："+ item.getTask_coupon_overdate())
            ;

            if (1==item.getSign()){//未使用

                helper
                        .setTextColor(R.id.item_gift_money,MyApp.getApp().getResources().getColor(R.color.white))
                        .setTextColor(R.id.item_gift_name,MyApp.getApp().getResources().getColor(R.color.white))
                        .setTextColor(R.id.item_gift_condition,MyApp.getApp().getResources().getColor(R.color.white))
                        .setTextColor(R.id.item_gift_time, MyApp.getApp().getResources().getColor(R.color.white))
                        .setTextColor(R.id.item_gift_symbol,MyApp.getApp().getResources().getColor(R.color.white))
                ;
                ((LinearLayout) helper.getView(R.id.item_gift_ll))
                        .setBackgroundDrawable(MyApp.getApp().getResources().getDrawable(R.drawable.gift_normal));
            } else {
                helper
                        .setTextColor(R.id.item_gift_money,MyApp.getApp().getResources().getColor(R.color.color_text_grey))
                        .setTextColor(R.id.item_gift_name,MyApp.getApp().getResources().getColor(R.color.color_text_grey))
                        .setTextColor(R.id.item_gift_condition,MyApp.getApp().getResources().getColor(R.color.color_text_grey))
                        .setTextColor(R.id.item_gift_time, MyApp.getApp().getResources().getColor(R.color.color_text_grey))
                        .setTextColor(R.id.item_gift_symbol,MyApp.getApp().getResources().getColor(R.color.color_text_grey))
                ;
                ((LinearLayout) helper.getView(R.id.item_gift_ll))
                        .setBackgroundDrawable(MyApp.getApp().getResources().getDrawable(R.drawable.gift_used));
            }

        }
    }
}